#ifndef DFSALGORITHM_H
#define DFSALGORITHM_H

#include "searchalgorithm.h"
#include <stack>
#include <chrono>

class DFSAlgorithm : public SearchAlgorithm
{
public:
    DFSAlgorithm(int maxDepth = 50);
    
    // 重写基类方法
    SearchResult search(const PuzzleState& initial, const PuzzleState& goal) override;

    
    // 设置最大深度
    void setMaxDepth(int depth) { maxDepth = depth; }
    int getMaxDepth() const { return maxDepth; }

private:
    int maxDepth;
    
    // IDA*算法的递归搜索函数
    std::pair<std::shared_ptr<SearchNode>, bool> idaStarSearch(
        const PuzzleState& current, 
        const PuzzleState& goal,
        int g,  // 当前路径代价
        int threshold,  // f值阈值
        std::shared_ptr<SearchNode> parent,
        int action,
        int& nodesGenerated,
        int& nodesExpanded,
        int& nextThreshold,
        std::chrono::high_resolution_clock::time_point startTime,
        int timeLimit
    );
};

#endif // DFSALGORITHM_H